<template>
	<view class="container">
		<view class="top-bg">
			<u-navbar 
			isBack 
			title="查看详情" 
			background="rgba(0,0,0,0)"
			back-icon-color="#fff"
			title-color="#fff"></u-navbar>
			<view class="title">
				<text class="pay">已关闭</text>
			</view>
		</view>
		<view class="content">
			<view class="detail">
				<view class="detail-content">
					<view class="product df-bt">
						<view class="product-info df-ct">
							<image :src="list.headimg.path" mode="" class="product-img"></image>
							<view class="name">
								<view class="name-top">{{list.realname}}</view>
								<view class="phone">{{list.phone}}</view>
							</view>
						</view>
						<view class="iconfont icon-dadianhua" @click="toTelPhone"></view>						
					</view>
					<view class="top">
						<view class="size df-bt">
							<view class="">
								<view class="t">户型</view>
								<view>{{list.house_type}}</view>
							</view>
							<view class="">
								<view class="t">面积</view>
								<view>{{list.house_area}}m²</view>
							</view>
							<view class="right">
								<view class="t">小区</view>
								<view>{{list.estate}}</view>
							</view>
						</view>
						<view class="address">
							<view class="address-title t">
								装修地址
							</view>
							<view class="address-detail">
								{{list.address}}
							</view>
						</view>						
					</view>
				</view>				
			</view>
			<view class="contract">
				<view class="title">
					订单合同
				</view>
				<view class="upload" v-if="Array.isArray(list.contract_thumb_url)">
					<view class="imgBox" v-for="(item,index) in list.contract_thumb_url" :key="index">
						<image :src="item.path" mode="" @click="toViewImg(index,1)"></image>
						<!-- <image :src="`${baseimg}/static/constr/remove.png`" @click="removeImg(index)" mode=""></image> -->
					</view>
					<!-- <view class="uploadBtn" @click="uploadFN(1)">+<span>图片/PDF</span></view> -->
				    <!-- <u-upload ref="" :on-change="handleChange" :auto-upload="false" upload-text="图片/PDF"></u-upload> -->
				</view>
				<view class="upload" v-else>
					<view class="imgBox">
						<image :src="list.contract_thumb_url.path" @click="toViewImg(0,1)" mode=""></image>
					</view>
				</view>
			</view>
			<view class="contract">
				<view class="title">
					设计图纸
				</view>
				<view class="upload" v-if="Array.isArray(list.draw_thumb_url)">
					<view class="imgBox" v-for="(item,index) in list.draw_thumb_url" :key="index">
						<image :src="item.path" mode="" @click="toViewImg(index,2)"></image>
						<!-- <image :src="`${baseimg}/static/constr/remove.png`" @click="constrImgDel(index)" mode=""></image> -->
					</view>
					<!-- <view class="uploadBtn" @click="uploadFN(2)">+<span>添加图纸</span></view> -->
				    <!-- <u-upload ref="" :on-change="handleChange" :auto-upload="false" upload-text="图片/PDF"></u-upload> -->
				</view>
				<view class="upload" v-else>
					<view class="imgBox">
						<image :src="list.draw_thumb_url.path" @click="toViewImg(0,2)" mode=""></image>
					</view>
				</view>
			</view>
			<view class="contract">
				<view class="title">
					选材单
				</view>
				<view class="upload" v-if="Array.isArray(list.material_thumb_url)">
					<view class="imgBox" v-for="(item,index) in list.material_thumb_url" :key="index">
						<image :src="item.path" mode="" @click="toViewImg(index,3)"></image>
						<!-- <image :src="`${baseimg}/static/constr/remove.png`" @click="constrImgDel(index)" mode=""></image> -->
					</view>
					<!-- <view class="uploadBtn" @click="uploadFN(2)">+<span>添加图纸</span></view> -->
				    <!-- <u-upload ref="" :on-change="handleChange" :auto-upload="false" upload-text="图片/PDF"></u-upload> -->
				</view>
				<view class="upload" v-else>
					<view class="imgBox">
						<image :src="list.material_thumb_url.path" @click="toViewImg(0,3) "mode=""></image>
					</view>
				</view>
			</view>
			<view class="message">
				<view class="title">
					订单信息
				</view>
				<view class="appeal">
					<text class="left">客户诉求</text>
					<text class="right-appeal">{{list.remark}}</text>
				</view>
				<view class="number df">
					<text class="left">订单编号</text>
					<text class="center">{{list.order_no}}</text>
					<text class="copy" @click="copyBtn">复制</text>
					
				</view>
				<view class="time df">
					<text class="left">下单时间</text>
					<text class="right">{{list.create_time | dateformat("YYYY-MM-DD HH:mm:ss")}}</text>
				</view>
			</view>
			<view class="message">
				<view class="title">
					支付信息
				</view>
				<view class="money df">
					<text class="left">合同金额</text>
					<text class="total-money">¥ {{list.contract_price}}</text>
				</view>
				<view class="appeal">
					<text class="left">支付次数</text>
					<text class="right-appeal">{{list.pay_progress.length}}</text>
				</view>
				<view class="time df">
					<text class="left">支付比例</text>
					<text class="right">{{list.pay_rule?list.pay_rule.replace(/,/g,'、'):''}}</text>
				</view>
				<!-- 支付比例 -->
				<view class="payNumList">
					<view class="item" v-for="(item,index) in list.pay_progress" :key="index">
						<view class="info">
							<view class="num">{{index+1}}</view>
							{{item.rate*100}}%
							<text>(￥{{item.amount}})</text>
						</view>
						<view class="btn">{{item.pay_status!=2?'未付款':'已付款'}}</view>
					</view>
				</view>
				<!-- 备注 -->
				<view class="remarksBox">
					<view class="title">
						备注
					</view>
					<view class="textarea">
						 <textarea disabled v-model="list.pay_rule_desc" maxlength="1000" placeholder-style="color:#D8D8D8" placeholder="备注信息~"/>
					</view>
				</view>
			</view>
		</view>
		<view class="footer">
			<button type="default" class="btn-text" @click="toDelOrder">删除订单</button>
			<!-- <button type="default" class="btn-text" @click="toEdit">修改信息</button> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseimg:this.$static,
				show:false,
				content:"确认删除此订单吗",
				list:{},
				order_id:null
			}
		},
		onLoad(option) {
			this.order_id = option.id
			this.getDetail()
		},
		methods:{
			// 获取订单详情
			getDetail(){
				let params = {
					id:this.order_id
				}
				this.$api.designerOrder_getDetail(params).then(res=>{
					console.log(res,'已关闭详情')
					if(res.code == 1){
						this.list = res.data		
					}
				})
			},
			// 联系打电话
			toTelPhone(){
				console.log(this.list.phone,'电话电话')
				uni.makePhoneCall({
				 	// 手机号
				    phoneNumber: this.list.phone, 
					// 成功回调
					success: (res) => {
						console.log('调用成功!')	
					},
					// 失败回调
					fail: (res) => {
						console.log('调用失败!')
					}
				});
			},
			
			// 复制按钮
			copyBtn(){
				uni.setClipboardData({
				    data: this.list.order_no,
				    success: function () {
						console.log('复制成功')
				    }
				});
			},
			
			// 删除订单
			toDelOrder(){
				uni.showModal({
					content:'确定删除此订单吗？',
					success:res=>{
						if(res.confirm){
							this.$api.designerOrder_del({id:this.order_id}).then(res=>{
								console.log(res,'删除结果')
								if(res.code==1){
									uni.showToast({
										title:'删除成功',
										icon:'success'
									})
									setTimeout(function(){
										uni.navigateBack({
											delta:1
										})
									},300)
								}
							})
						}
					}
				})
			},
			
			// 图片预览
			toViewImg(index,type) { //type=1合同，type=2施工图纸，type=3选材单
				let imgArr = type==1?this.list.contract_thumb_url:type==2?this.list.draw_thumb_url:this.list.material_thumb_url;
				let urlType = Array.isArray(imgArr)
				console.log(imgArr,'需要预览的图片')
				let imgUrl = []
				if (urlType) {
					imgArr.map(item => {
						imgUrl.push(item.path)
					})
				} else {
					imgUrl.push(imgArr.path)
				}
				uni.previewImage({
					current: index, //预览图片的下标
					urls: imgUrl //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
				});
			},
			
			handleModal(){
				console.log(123)
				 this.show = true
			},
		}
	}
</script>

<style lang="less" scoped>
	.container{
		.top-bg{
			background:  url(https://manager.ryz1620.com/static/home-personal/personal-bg.png) no-repeat top;
			width: 100%;
			height: 468rpx;
			position: relative;
			/deep/ .u-navbar .u-border-bottom{
						border: 0 !important;
			}
			.title{
				display: flex;
				margin: 80rpx 0 0 44rpx;				
				.pay{
					font-size: 36rpx;
					font-family: PingFang SC;
					font-weight: 500;
					line-height: 36rpx;
					color: #FFFFFF;
				}
			}			
		}
		.content{
			position: absolute;
			left: 0;
			top: 350rpx;
			z-index: 99;
			padding: 24rpx 24rpx 0rpx 24rpx;
			padding-bottom: constant(safe-area-inset-bottom);
			padding-bottom: env(safe-area-inset-bottom);
			margin-bottom: 150rpx;
			width: 100%;
			.detail{
				// padding: 0 24rpx;
				
				.detail-content{
					background-color: #fff;
					padding: 30rpx 24rpx;
					margin-bottom: 22rpx;
					border-radius: 16rpx;
					.top{
						padding: 28rpx;
						background: #F8F8F8;
						border-radius: 8rpx;
						color: #505050;
						margin-bottom: 30rpx;
						.size{
							margin-bottom: 40rpx;
							.right{
								display: flex;
								flex-direction: column;
								justify-content: flex-end;
								text-align: right;
								// align-items: right;
								}
						}
						.address{
							
							.address-detail{
								font-size: 26rpx;
								font-family: PingFang SC;
								font-weight: 400;
								line-height: 40rpx;
								color: #505050;
							}
						}
							.t {
								font-size: 22rpx;
								font-family: PingFang SC;
								font-weight: 400;
								line-height: 36rpx;
								color: #A0A0A0;
							}
							
						
						
					}
					.product {
						padding-bottom: 30rpx;
						// padding-top: 22rpx;
						.product-img {
							width: 84rpx;
							height: 84rpx;
							border-radius: 50%;
							margin-right: 20rpx;
						}
						.name{
							.name-top{
								font-size: 26rpx;
								font-weight: 500;
								line-height: 40rpx;
								color: #0A0605;
							}
							.phone{
								font-size: 26rpx;
								font-weight: 400;
								line-height: 40rpx;
								color: #505050;
							}
						}
						
						.iconfont{font-size: 50rpx;}
					}
					
					.btn-box {
						&:after { display: block; clear: both; content: ''; visibility: hidden; height: 0; }
						.more {
							float: left;
							font-size: 26rpx;
							font-family: PingFang SC;
							font-weight: 400;
							line-height: 40rpx;
							color: #A0A0A0;
							padding-top: 10rpx;
						}
						.price-box {
							text-align: right;
							padding: 40rpx 0 22rpx 0;
							font-size: 26rpx;
							font-family: PingFang SC;
							font-weight: 500;
							line-height: 20rpx;
							color: #878787;
							.d-price {
								color: #dfb368;
								font-size: 32rpx;
								padding-left: 20rpx;
							}
						}
						.btn {
							// width: 50%;
							// float: right;
							display: flex;
							justify-content:flex-end ;
							align-items: center;
							.btn-text {
								width: 172rpx;
								height: 64rpx;
								background: #FFFFFF;
								border: 2rpx solid #505050;
								opacity: 1;
								border-radius: 32rpx;
								text-align: center;
								line-height: 64rpx;
								color: #505050;
								font-size: 26rpx;
								margin: 0 10rpx;
							}
							.active{
								background-color: #DBA954;
								color: #fff;
								border: 0;
							}
						}
						
					}
				}
			}
			.contract{
				padding: 24rpx;
				background-color: #fff;
				border-radius: 16rpx;
				margin-top: 30rpx;
				.title{
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					line-height: 40rpx;
					color: #0A0605;
				}
				.upload{
					margin-top: 40rpx;
					display: flex;
					align-items: center;
					flex-wrap: wrap;
					.imgBox{
						margin: 0 5rpx 10rpx;
						position: relative;
						width: 200rpx;
						height: 200rpx;
						border-radius: 4rpx;
						image:nth-child(1){
							width: 100%;
							height: 100%;
							border-radius: 4rpx;
						}
						image:nth-child(2){
							width: 50rpx;
							height: 50rpx;
							position: absolute;
							top: 5rpx;
							right: 5rpx;
						}
					}
					.uploadBtn{
						margin: 0 5rpx 10rpx;
						background-color: #F8F8F8;
						border-radius: 4rpx;
						width: 200rpx;
						height: 200rpx;
						font-size: 60rpx;
						display:  flex;
						align-items: center;
						color: #A0A0A0;
						flex-direction: column;
						justify-content: center;
						span{font: 400 22rpx/36rpx PingFang SC;}
					}
				}
			}
			.message{
				padding: 24rpx;
				background-color: #fff;
				border-radius: 16rpx;
				margin-top: 30rpx;
				.title{
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					line-height: 40rpx;
					color: #0A0605;
				}
				.left{
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 400;
					line-height: 40rpx;
					color: #A0A0A0;
					display: inline-block;
					// margin-right: 10rpx;
					width: 27%;
				}
				.right{
					font-size: 26rpx;
					font-family: PingFang SC;
					font-weight: 400;
					line-height: 40rpx;
					color: #505050;
				}
				.copy{
					padding: 6rpx 18rpx;
					background-color: rgba(219, 169, 84, 0.1);
					font-size: 18rpx;
					font-family: PingFang SC;
					font-weight: 400;
					line-height: 20rpx;
					color: #DBA954;
					border-radius: 18rpx;
					margin-left: 10rpx;
				}
				.total-money{
					color: #DBA954;
				}
				.right-appeal{
					width: 73%;
					// margin-left: 62rpx;
				}
				.df{
					margin: 20rpx 0;
				}
				// 支付比例列表
				.payNumList{
					.item{
						display: flex;
						justify-content: space-between;
						align-items: center;
						margin: 30rpx 0;
						.info{
							display: flex;
							align-items: center;
							.num{
								width: 30rpx;
								height: 30rpx;
								border: 2rpx solid #A0A0A0;
								border-radius: 50%;
								text-align: center;
								font-size: 22rpx;
								line-height: 30rpx;
								margin-right: 20rpx;
							}
							text{
								color: #DCAB58;
								margin-left: 20rpx;
							}
						}
						.btn{
							color: #DCAB58;
						}
						.active{
							padding: 8rpx 30rpx;
							border-radius: 28rpx;
							color: #fff;
							background: linear-gradient(90deg, #DBA954 0%, #EABA6A 100%);
						}
					}
				}
				// 备注
				.remarksBox{
					// padding: 24rpx;
					background-color: #fff;
					border-radius: 16rpx;
					margin-top: 30rpx;
					.title{
						font-size: 30rpx;
						font-family: PingFang SC;
						font-weight: 500;
						line-height: 40rpx;
						color: #0A0605;
					}
					.textarea{
						background: #F8F8F8;
						padding: 24rpx;
						height: 160rpx;
						overflow-y: auto;
						margin-top: 20rpx;
					}
				}
			}
		}
		.footer{
			height: 120rpx;
			width: 100%;
			background-color: #fff;
			position: fixed;
			left: 0;
			bottom: 0;
			z-index: 99;
			padding:0 30rpx;
			display: flex;
			justify-content:flex-end ;
			align-items: center;
			height: calc(120rpx+ constant(safe-area-inset-bottom)); 			height: calc(120rpx + env(safe-area-inset-bottom));			padding-bottom: constant(safe-area-inset-bottom);			padding-bottom: env(safe-area-inset-bottom);
			.btn-text {
				width: 172rpx;
				height: 64rpx;
				background: #FFFFFF;
				border: 2rpx solid #505050;
				opacity: 1;
				border-radius: 32rpx;
				text-align: center;
				line-height: 64rpx;
				color: #505050;
				font-size: 26rpx;
				margin: 0 10rpx;
			}
			.active{
				background-color: #DBA954;
				color: #fff;
				border: 0;
				width: 240rpx;
			}
		}
	}
</style>

